package action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import dao.ProductDAO;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;

import pojo.Product;

import com.opensymphony.xwork2.ActionSupport;

public class CompareAction extends ActionSupport implements RequestAware, SessionAware {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3042502860673930160L;
	private Map<String, Object> request;
    private Map<String, Object> session;
    
    @Autowired
    private ProductDAO ProductDAO;
    
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
	}

	public void setRequest(Map<String, Object> arg0) {
		this.request = arg0;
	}
	
	private String sku0 = "";
	public void setSku0(String sku0) {
		this.sku0 = sku0;
	}

	private String sku1 = "";
	public void setSku1(String sku1) {
		this.sku1 = sku1;
	}

	private String sku2 = "";
	public void setSku2(String sku2) {
		this.sku2 = sku2;
	}

	private String sku3 = "";
	public void setSku3(String sku3) {
		this.sku3 = sku3;
	}

	public String execute() {
        
		List<Product> products = new ArrayList<Product>();
		products.add(ProductDAO.getProductBySKU(sku0));
		products.add(ProductDAO.getProductBySKU(sku1));
		products.add(ProductDAO.getProductBySKU(sku2));
		products.add(ProductDAO.getProductBySKU(sku3));
		
		request.put("products", products);
        return SUCCESS;
    }
}
